package com.fu.team.service;

import com.fu.team.domain.Employee;
import com.fu.team.domain.Equipment;
import com.fu.team.domain.PC;

import static com.fu.team.service.Data.*;

/**
 * @author 付大大
 * @description 负责将Date中的数据封装到Employee[]数组中，同时提供相关操作Employee[]的方法
 * @create 2021-01-10 19:45
 */
public class NameListService {
    private Employee[] employees;

    /**
     * 给employees数组及数组元素进行初始化
     */
    public NameListService() {
        employees = new Employee[EMPLOYEES.length];

        for (int i = 0; i < employees.length; i++) {
            //获取员工类型
            int type = Integer.parseInt(EMPLOYEES[i][0]);
            //获取employee的四个基本信息
            int id = Integer.parseInt(EMPLOYEES[i][1]);
            String name = EMPLOYEES[i][2];
            int age = Integer.parseInt(EMPLOYEES[i][1]);
            double salary = Double.parseDouble(EMPLOYEES[i][4]);


            switch (type) {
                case EMPLOYEE:
                    employees[i] = new Employee(id, name, age, salary);
                    break;
                case PROGRAMMER:
                    Equipment equipment = createEquipment(i);
//                    employees[i]=new Programmer(id,name,age,)
                    break;
                case DESIGNER:
                    break;
                case ARCHITECT:
                default:
                    break;
            }
        }
    }

    /**
     * 获取指定索引上的员工设备
     *
     * @param index
     * @return
     */
    private Equipment createEquipment(int index) {
        int type = Integer.parseInt(EQUIPMENTS[index][0]);

        switch (type) {
            case PC:
                return new PC(EQUIPMENTS[index][1], EQUIPMENTS[index][2]);
            case NOTEBOOK:
                break;
            case PRINTER:
                break;
            default:
                break;
        }
        return null;
    }

    public Employee[] getAllEmployees() {
        return null;
    }

    public Employee getEmployee(int id) {
        return null;
    }

}
